package cn.geckos.ioc.parsing
{
	import flash.xml.XMLNode;
	import flash.utils.Dictionary;
	
	public class XMLValidator
	{
		private static const beans:Dictionary = 
		["must":["bean"],
		 "opt" :["import"]];
		
		private static const bean:Dictionary = 
		["must":["id", "clazz"] , 
		 "opt" :["scope","init", "destory"]];
		 
		private static const property:Dictionary = 
		["must":["name"], 
		 "opt" :["value", "ref"]];
		 
		private static const ref:Dictionary = 
		["must":["bean"]];
		 
		private static const map:Dictionary = 
		["must":[], 
		 "opt" :[]]
		
		public function check(xml:XML):void
		{
			if(xml == null || xml == undefined) throw new Error("Config File can not be Empty");
			beans(xml);
			for each(var node:XML in xml.children())
			{
				beans(node);
			}
		}
		
		protected function beans(node:XML):void
		{
			if(node.name() != "beans") throw new Error("The name of root node must be Beans!");
		}
		protected function bean(node:XML):void
		{
			if(node.name() == "bean")
			{
				if(node.@id == null || node.@id == undefined) throw new Error("The attitude id in bean missed");
				
			}else
			{
				throw new Error("the name of the son of the root node defined incorrect!");
			}
		}
		protected function property(node:XML):void
		{
			
		}
		protected function map(node:XML):void
		{
			
		}
		protected function stack(node:XML):void
		{
			
		}
		protected function reference(node:XML):void
		{
			
		}
	}
}